import Vue from "vue";
import VueRouter from "vue-router";
// import login from '../views/login/login.vue'

Vue.use(VueRouter);

const routes = [{
    path: '/login',
    name: "login",
    component: () => import('@/views/login')
  }, {
    path: "/detailed",
    name: "detailed",
    component: () => import("@/views/personnel/components/detailed")
  }, {
    path: '/',
    name: 'layout',
    redirect: '/home',
    component: () => import('@/views/layout'),
    children: [{
      path: '/home',
      name: "home",
      meta: {
        keepAlive: true,
        scrollTop: 0
      },
      component: () => import('@/views/home')
    }, {
      path: '/company',
      name: "company",
      component: () => import('@/views/company'),
      meta: {
        keepAlive: true
      }
    }, {
      path: '/personnel',
      name: "personnel",
      component: () => import('@/views/personnel')
    }, {
      path: '/mine',
      name: "mine",
      component: () => import('@/views/mine')
    }]
  },
  {
    path: "/information",
    name: "information",
    component: () => import("@/views/mine/components/my-information")
  },
  {
    path: '/goods_detail/:cat_id',
    name: "goods_detail",
    component: () => import('@/views/goods_detail'),
    props: true,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: () => import('@/views/article'),
    props: true // 开启 Props 传参，说白了就是把路由参数映射到组件的 props 数据中
  }, {
    path: '/my-address',
    name: "my-address",
    component: () => import('@/components/my-address'),
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/components/search'),
    props: true // 开启 Props 传参，说白了就是把路由参数映射到组件的 props 数据中
  },
  {
    path: '/pull-cargo',
    name: 'pull-cargo',
    component: () => import('@/views/home/components/pull-cargo'),
    props: true // 开启 Props 传参，说白了就是把路由参数映射到组件的 props 数据中
  },
  {
    path: '/get-job',
    name: 'get-job',
    component: () => import('@/views/home/components/get-job'),
    props: true // 开启 Props 传参，说白了就是把路由参数映射到组件的 props 数据中
  },
  {
    path: '/narry-list',
    name: 'narry-list',
    component: () => import('@/views/home/components/narry-list'),
    props: true // 开启 Props 传参，说白了就是把路由参数映射到组件的 props 数据中
  },
  {
    path: '/narry-rec/:narryId',
    name: 'narry-rec',
    component: () => import('@/views/home/components/narry-rec'),
    props: true // 开启 Props 传参，说白了就是把路由参数映射到组件的 props 数据中
  },
  {
    path: '/my-order',
    name: "my-order",
    component: () => import('@/views/my-order'),
    props: true
  },
  {
    path: '/my-allorder',
    name: "myorder",
    component: () => import('@/views/my-allorder'),
  },
  {
    path: '/cleaning',
    name: "cleaning",
    component: () => import('@/views/home/components/cleaning'),
  },
  {
    path: '/move-house',
    name: "move-house",
    component: () => import('@/views/home/components/move-house'),
  }
]
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location, onResolve, onReject) {

  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)

  return originalPush.call(this, location).catch(err => err)

}


const router = new VueRouter({
  routes
});

export default router;
